<?php

namespace app\api\controller\v49;

use app\api\controller\v13\Auth2;
use app\common\cachemodel\ai_chat_room\AiChatRecord;

class AiChatRoom extends Auth2
{
    /**
     * 聊天室类型列表
     * @return \think\response\Json
     */
    public function getTypeList()
    {
        $configData = config('ai_chat_room.type_list');
        $list = [];
        foreach ($configData as $datum)
        {
            $list[] = [
                'type' => $datum['id'],
                'name' => $datum['name'],
                'desc' => $datum['desc'],
            ];
        }
        $btnList = [
            [
                'btn_name' => '打开内心 开始疗愈',
                'target' => 'local',
                'link' => 'heal_chat_room_create_option?need_auth=2',
                'style' => 1,
            ],
        ];
        $isNew = true;
        if ($this->user)
        {
            request()->get(['page' => 1, 'limit' => 1]);
            $aiChatRecordModel = new AiChatRecord();
            $aiChatRecordModel->setPageLimit(1);
            $pageData = $aiChatRecordModel->getListPage($this->user['id'], 'update_time', [], 0, 'desc', 0);
            $isNew = $pageData['total'] > 0 ? false : true;
        }
        if ($isNew)
        {
            $btnList[] = [
                'btn_name' => '暂时跳过',
                'target' => 'local',
                'link' => 'heal_chat_room_list?need_auth=2',
                'style' => 2,
            ];
        }
        $resData = [
            'img_hi' => '/test/ai_chat_room/hi.png',
            'list' => $list,
            'btn_list' => $btnList,
            'intro_list' => ['我一直在等你', '很开心你能来，从这一刻起', '打开内心，一切都会慢慢好起来', '先聊聊你想获得哪方面的帮助吧！'],
        ];

        return show(config('code.success'), '请求成功', $resData);
    }
}